package com.tian.producer;

import com.alibaba.fastjson.JSON;
import com.tian.enums.MessageRetryTypeEnum;
import com.tian.enums.ChargeStationRabbitMQConstant;
import com.tian.message.ChargingDataMessage;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-25 16:10
 * {@code @version:} 1.0
 */
@Component
public class ChargingRecordProducer {
    @Resource
    private BaseProducer baseProducer;

    public void send(ChargingDataMessage chargingDataMessage) {
        String content= JSON.toJSONString(chargingDataMessage);
        baseProducer.sendWithRetry(content, MessageRetryTypeEnum.CHARGING_RECORD_PRODUCER.getCode(),
                chargingDataMessage.getReqId(), ChargeStationRabbitMQConstant.CHARGING_RECORD_EXCHANGE, ChargeStationRabbitMQConstant.CHARGING_RECORD_ROUTING_KEY ); // 发送消息
    }
}
